WEBVTT

00:01.070 --> 00:07.470
In the last video we discovered that investing in the S&amp;P 500 fund investment period of three years

00:07.770 --> 00:14.400
can be a really volatile and risky investment depending on when and at which market conditions you are

00:14.400 --> 00:15.600
investing.

00:15.600 --> 00:22.620
So in this video we want to calculate the rolling return of the S&amp;P 500 for different investment periods

00:22.620 --> 00:24.950
from one year to 20 years.

00:24.960 --> 00:31.290
So in other words we will calculate the annualized average monthly returns with rolling windows from

00:31.290 --> 00:34.060
a twelve month to 240 month.

00:34.530 --> 00:41.200
So that's 20 years and we want to discover whether there is kind of a time diversification effect.

00:41.310 --> 00:47.070
People typically say that stocks are long term investment Bear and the good days you recover the losses

00:47.100 --> 00:53.280
made and the bad days and we try to prove and visualize this in the next minutes.

00:53.280 --> 00:58.230
So first of all we import us and we also import met plot lip.

00:59.020 --> 01:03.310
Then we are again working with the S&amp;P 500 see a three fire.

01:03.960 --> 01:05.280
So let's have a look here.

01:05.790 --> 01:12.030
So we are working only here with the closing prices and we can also call you the info method.

01:12.060 --> 01:14.410
So this is actually nothing new.

01:14.570 --> 01:20.070
And we can also plot um the S&amp;P 500 price from the 70s to today.

01:22.520 --> 01:31.320
So this was a pretty good investment if you invested in the S&amp;P 500 in the 70s and again also in this

01:31.320 --> 01:38.050
video we are working with monthly returns and therefore we need to recycle but here the closing prices

01:38.060 --> 01:41.820
to monthly and we calculate the percentage change.

01:41.820 --> 01:43.580
So this is nothing new.

01:44.190 --> 01:51.600
And let's have a look at the last five monthly returns here in 2000 and 18 and to avoid any confusion

01:51.600 --> 01:54.850
we rename here the column Labor Forum.

01:54.900 --> 01:59.190
Close the two monthly returns based on closing prices.

01:59.190 --> 02:02.940
So this is actually also nothing new.

02:03.030 --> 02:04.860
So let's again have a look here.

02:04.860 --> 02:10.410
So now our monthly returns column has that label monthly returns.

02:10.410 --> 02:16.980
And actually in the last video we calculated the rolling average return and the rolling standard deviation

02:16.980 --> 02:20.120
of returns for the last to 36 months.

02:20.940 --> 02:24.930
So let's repeat this here for the rolling returns.

02:24.930 --> 02:29.900
So we you see the rolling method and we multiply our desired investment period.

02:29.910 --> 02:33.180
So here three years by twelve twelve months.

02:33.210 --> 02:35.250
So in total we have 36 months.

02:35.790 --> 02:44.040
And then we calculate the rolling mean and by multiplying this uh with 12 we get actually annualized.

02:44.130 --> 02:45.360
Rolling mean returns.

02:45.350 --> 02:47.700
So this is also nothing new.

02:47.760 --> 02:49.010
Let's do this here.

02:49.260 --> 02:52.890
And apparently in the first thirty five months we have any end value.

02:52.890 --> 03:00.370
So no surprise here and now we actually want to do the same for investment periods of one year five

03:00.370 --> 03:03.090
years 10 years and 20 years.

03:03.250 --> 03:08.790
And we use here a for loop so we iterate over the investment period.

03:08.800 --> 03:11.530
So four years in uh the lists here.

03:11.530 --> 03:18.460
So we have 1 3 5 10 and 20 year and for each of these five investment periods you want to add here to

03:18.460 --> 03:22.510
our monthly returns data frame a new column.

03:22.510 --> 03:27.760
So we want to add to your column for the one year rolling return for our three year rolling return 5

03:27.790 --> 03:29.770
10 and 20 year.

03:30.040 --> 03:35.770
And we can actually create the columns with this column labeled here with this code here and let's have

03:35.770 --> 03:36.820
a look at an example.

03:36.820 --> 03:39.270
So let's take year the one year period.

03:39.640 --> 03:46.720
So we are creating here the one year column with the column label one year and what we are doing actually

03:46.720 --> 03:49.540
we take here the column monthly returns.

03:49.540 --> 03:51.600
So these are the monthly returns.

03:51.700 --> 03:58.120
Then we apply the rolling method and for the rolling window we are actually calculating here a yes times

03:58.120 --> 03:59.090
twelve.

03:59.140 --> 04:02.390
So in the very first iteration yes that's equal to 1.

04:02.620 --> 04:11.140
So one time twelve gives us a twelve as a window that we are calculating the mean and we are analyzing

04:11.140 --> 04:15.660
it and thus we are doing here for all five periods.

04:15.730 --> 04:19.180
So one year three year five year 10 year and 20 year.

04:19.180 --> 04:21.680
And by doing so we're creating five columns.

04:21.700 --> 04:30.280
So let's do this year and let's have a look here at the last five rows of our data frame.

04:30.340 --> 04:37.180
So here we have added successfully the columns one year three year five year 10 year and 20 year and

04:37.180 --> 04:39.240
let's have a look at the very last row.

04:39.640 --> 04:42.970
So this is December to 18.

04:43.000 --> 04:45.240
And if we have a look here at the column one year.

04:45.260 --> 04:53.170
So we have a minus 6 percent and this is actually the annualized the mean return over the last 12 months

04:53.860 --> 04:59.380
and consequently here in the column 3 year we have a seven point one percent.

04:59.380 --> 05:05.570
And this is actually the annualized the mean return for the preceding thirty six month period form to

05:05.570 --> 05:07.810
a sixteen to to 18.

05:08.230 --> 05:12.000
And that's also if I look at the 20 year column.

05:12.250 --> 05:20.260
So here we have an annualized monthly return of 4.5 percent and this is actually the mean return over

05:20.260 --> 05:23.310
the last 240 months.

05:23.620 --> 05:25.260
And we can also create a plot.

05:25.290 --> 05:28.110
Um this this uh five columns.

05:28.300 --> 05:31.240
So we are selecting the last five columns.

05:31.240 --> 05:40.540
And uh let's see what we got here so uh here we can see on the x axis the respective date and on the

05:40.540 --> 05:41.620
y axis.

05:41.710 --> 05:43.300
The annualized return.

05:43.870 --> 05:50.140
And here we have actually five lines uh which are actually are rolling statistics are rolling returns.

05:50.140 --> 05:56.500
So the blue line here is the the rolling return on the investment period of one year.

05:56.620 --> 06:00.200
And this is actually quite volatile as you can see here.

06:00.220 --> 06:07.780
So if you have invested in 2 8 and divested and 2 9 then in this case you've got a negative annualized

06:07.780 --> 06:11.100
return of uh let's say minus 50 percent.

06:11.230 --> 06:15.300
And in contrast the few invested and 2 9 2 to 10.

06:15.330 --> 06:21.700
Then you analyze them mean return would be around 40 percent and you can also see here that the longer

06:21.700 --> 06:26.670
the investment period the less volatile our graph is here.

06:26.680 --> 06:30.100
So we have here the green graph within the investment period of three years.

06:30.790 --> 06:38.680
And the yellow curve which is not volatile at all actually was on the rolling investment period of 20

06:38.680 --> 06:39.530
years.

06:39.730 --> 06:46.480
And we can also create subplots to have a better view here and we can do a service of the subplots perimeter

06:46.510 --> 06:47.650
and pass see a true

06:54.320 --> 06:57.710
so for each investment period we have here now a subplot.

06:57.710 --> 07:04.060
And we can also increase here the figure size to let's say 50 and uh 40

07:10.200 --> 07:16.920
so we are starting here with a one year investment period and the rolling return and uh the rolling

07:17.160 --> 07:21.970
return this year between minus 50 percent and plus 40 percent.

07:21.990 --> 07:25.520
Then we have a look here at the three year rolling return.

07:25.740 --> 07:32.250
And this is already here between a minus let's say 15 percent and plus the 25 percent.

07:32.250 --> 07:36.810
Then we have the five year rolling return and the 10 year rolling return.

07:36.870 --> 07:39.970
And then finally the 20 year rolling return.

07:40.110 --> 07:45.600
And as we can see here on the left hand side the scale is different than for the other graphs subplots.

07:45.630 --> 07:52.920
So the 20 year annualized rolling return is between a plus 5 percent and 14 percent.

07:52.920 --> 08:00.270
So in the history of the S&amp;P 500 index there's actually no 20 year period where we actually made the

08:00.270 --> 08:00.740
losses.

08:00.740 --> 08:08.460
So after 20 years we are always positive actually so we gained or we increased our investment.

08:08.460 --> 08:16.170
And uh this is uh different to uh let's say the 10 year or the five year or even the the one year investment

08:16.170 --> 08:16.620
period.

08:16.650 --> 08:22.300
So here it's quite likely that over one year we make losses also.

08:22.710 --> 08:28.220
And we can even better see this effect by passing true to the share by parameter

08:32.020 --> 08:39.450
and by doing so for each subplot we I have actually the uh y axis of uh the one year period.

08:39.520 --> 08:46.450
So here we have the returns between minus 40 and the 40 percent and we can see here.

08:46.470 --> 08:54.860
So one year is quite volatile and the SBA increases the investment period the volatility decreases.

08:54.970 --> 08:58.210
So this is quite obvious here.

08:58.210 --> 09:06.520
So finally with 20 years period there's hardly any volatility here so as a summary we can agree that

09:06.580 --> 09:09.810
that's kind of a time diversification effect.

09:10.090 --> 09:16.690
And uh the longer the investment period the less likely it is that you will suffer losses.

09:16.750 --> 09:23.590
So actually stocks a risky investment and it's quite likely that over a period of 1 to 5 for 10 years

09:23.620 --> 09:28.100
you made some losses but were periods of 15 or 20 years.

09:28.220 --> 09:34.420
It's uh at least if you have a look at historical data it's quite unlikely that you'll lose money over

09:34.420 --> 09:40.590
that long time periods and uh with this we are finished with this video and I hope to see you also and

09:40.590 --> 09:41.620
the next one by.
